﻿using System;
using System.Threading.Tasks;

namespace WinRTDatabase.Core
{
    /// <summary>
    /// Interface that is used for tables in a database
    /// </summary>
    public interface ITable
    {
        /// <summary>
        /// If a table is named, contains table name, otherwise empty string
        /// </summary>
        string TableName { get; }

        /// <summary>
        /// Type of object that database contains
        /// </summary>
        Type RowType { get; }

        /// <summary>
        /// Save table le to the Isolated Storage
        /// </summary>
        Task<SaveResult> SaveAsync();

        /// <summary>
        /// Set internal variables data when a table is de-serialized
        /// </summary>
        /// <param name="database">Database that table belongs to</param>
        /// <param name="tableName">If a table is named, contains table name, otherwise empty string</param>
        /// <param name="markClean">If set to true, table will be mark as clean</param>
        void SetTableDefinition(Database database, string tableName = "", bool markClean = true);

        /// <summary>
        /// Returns true of any data in the table has been changed by the user.
        /// This includes changes to rows, addition or removal of rows.
        /// </summary>
        bool IsDirty { get; }

    }
}
